﻿<Window xmlns:eisiWare="clr-namespace:eisiWare;assembly=NumericUpDown"  x:Class="Farkhod.BulkImageResizer.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:Farkhod.BulkImageResizer"
        xmlns:helpers="clr-namespace:Farkhod.BulkImageResizer.Helpers"
        xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"  
        Title="Bulk Image Resizer by Farkhod" SizeToContent="Height" Width="540" Icon="BIRLogo.ico" Closed="Window_Closed">
    <Window.Resources>
        <SolidColorBrush x:Key="brushWatermarkBackground" Color="White" />
        <SolidColorBrush x:Key="brushWatermarkBorder" Color="Indigo" />
        <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
        <helpers:WatermarkHelper x:Key="Helper" />
        <Style x:Key="EntryFieldStyle" TargetType="Grid" >
            <Setter Property="HorizontalAlignment" Value="Stretch" />
            <Setter Property="VerticalAlignment" Value="Center" />
            <Setter Property="Margin" Value="20,0" />
        </Style>
    </Window.Resources>
    <DockPanel>
        <Grid DockPanel.Dock="Top">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="104"/>
                <ColumnDefinition Width="213*"/>
                <ColumnDefinition Width="75"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="35"/>
                <RowDefinition Height="35"/>
                <RowDefinition Height="35"/>
                <RowDefinition Height="35*"/>
                <RowDefinition Height="35*"/>
                <RowDefinition Height="35*"/>
                <RowDefinition Height="35*"/>
                <RowDefinition Height="35"/>
            </Grid.RowDefinitions>
            <TextBlock Grid.Row="0" Grid.Column="0" Margin="0,5,0,0" HorizontalAlignment="Right">Source Folder:</TextBlock>
            <Grid Grid.Row ="0" Grid.Column="1">
                <TextBlock Margin="10,8" Text="Please select a folder containing image files to be converted..." Foreground="LightGray">
                    <TextBlock.Visibility>
                        <MultiBinding Converter="{StaticResource Helper}">
                            <Binding ElementName="txtSourceFolder" Path="Text.IsEmpty" />
                            <Binding ElementName="txtSourceFolder" Path="IsFocused" />
                        </MultiBinding>
                    </TextBlock.Visibility>
                </TextBlock>
                <TextBox Margin="5,5,5,5" x:Name="txtSourceFolder" Background="Transparent" />
            </Grid>
            <Button Grid.Row="0" Grid.Column="2" Content="Browse..." Margin="0,5,5,5" Name="btnSelectSourceFolder" Click="btnSourceFolder_Click"  />
            <TextBlock Grid.Row="1" Grid.Column="0" Margin="0,5,0,0" HorizontalAlignment="Right">Destination Folder:</TextBlock>
            <Grid  Grid.Row="1" Grid.Column="1">
                <TextBlock Margin="10,8" Text="Please select a destination folder..." Foreground="LightGray">
                    <TextBlock.Visibility>
                        <MultiBinding Converter="{StaticResource Helper}">
                            <Binding ElementName="txtDestinationFolder" Path="Text.IsEmpty" />
                            <Binding ElementName="txtDestinationFolder" Path="IsFocused" />
                        </MultiBinding>
                    </TextBlock.Visibility>
                </TextBlock>
                <TextBox Margin="5,5,5,5" Name="txtDestinationFolder" Background="Transparent"></TextBox>
            </Grid>
            <Button Grid.Row="1" Grid.Column="2" Content="Browse..." Margin="0,5,5,5" Name="btnDestinationFolder" Click="btnDestinationFolder_Click" />
            <Expander Grid.Row="2" Grid.ColumnSpan="3" Grid.RowSpan="5" Margin="0,5,0,0" Header="Settings" Name="expander">
                <Grid Margin="10,5,0,0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="206"/>
                        <ColumnDefinition Width="20*"/>
                        <ColumnDefinition Width="75"/>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="35"/>
                        <RowDefinition Height="35"/>
                        <RowDefinition Height="35"/>
                        <RowDefinition Height="35"/>
                    </Grid.RowDefinitions>
                    <Grid.Resources>
                        <local:DoubleToIntegerConverter x:Key="conv" />
                    </Grid.Resources>
                    <TextBlock Margin="0,5,0,0" Grid.Row="0" Grid.Column="0" HorizontalAlignment="Right">Default Destination Folder Name:</TextBlock>
                    <TextBox Name="txtDefDstFolderName" Grid.Row="0" Grid.Column="1" Margin="5,5,5,5">Output</TextBox>
                    <TextBlock Margin="0,5,0,0" Grid.Row="1" Grid.Column="0" HorizontalAlignment="Right">Default Postfix for Output File Names:</TextBlock>
                    <TextBox Name="txtDefPostfixFileNames" Grid.Row="1" Grid.Column="1" Margin="5,5,5,5">_out</TextBox>
                    <RadioButton Name="rbPercentage" Grid.Row="2" Grid.Column="0" Margin="0,5,0,0" IsChecked="True" HorizontalAlignment="Right">By Percentage:</RadioButton>
                    <TextBlock Grid.Row ="2" Grid.Column="2" Text="{Binding ElementName=rbPercentage, Path=Value, Converter={StaticResource conv}}" VerticalAlignment="Center" Margin="0,0,0,5" />
                    <Slider Margin="5,5,5,5" Grid.Row="2" Grid.Column="1" Maximum="300" Minimum="1" Name="slPercent" SmallChange="1" LargeChange="10" IsSnapToTickEnabled="True" IsMoveToPointEnabled="True" ValueChanged="slPercent_ValueChanged"/>
                    <StackPanel Orientation="Horizontal" Grid.Row="2" Grid.Column="2">
                        <Label Content="{Binding ElementName=slPercent,Path=Value}"/>
                        <Label Margin="-7,0,0,0" Content="%"/>
                    </StackPanel>
                    <RadioButton Name="rbSize" Grid.Row="3" Grid.Column="0" Margin="0,5,0,0" IsChecked="False" HorizontalAlignment="Right">By Dimensions:</RadioButton>
                    <Grid Grid.Row="3" Grid.Column="1">
                        <StackPanel Orientation="Horizontal">
                            <Label Margin="1,0,0,0">Height:</Label>
                            <eisiWare:NumericUpDown Name="udImageHeight" Margin="0,6" Width="65" Height="22" MaxValue="99999" Value="1" MinValue="1" MaxLength="5"/>
                            <Label Margin="1,0,0,0">Width:</Label>
                            <eisiWare:NumericUpDown Name="udImageWidth" Margin="0,6" Width="65" Height="22" MaxValue="99999" Value="1" MinValue="1" MaxLength="5"/>
                        </StackPanel>
                    </Grid>
                </Grid>
            </Expander>
            <Button Grid.Row="8" Grid.ColumnSpan="3" Content="Resize" Margin="5,5,5,5" Name="btnResize" Click="btnResize_Click" />
        </Grid>
        <StatusBar DockPanel.Dock="Bottom" Name="sbInfo" Background="White" Height="30" VerticalAlignment="Bottom">
                <TextBlock Name="tbMessage" TextAlignment="Left"></TextBlock>
                <Viewbox Width="25" Height="25" Name="vbProgress" Margin="5,0,0,0" VerticalAlignment="Center">
                    <local:CircularProgressBar  />
                </Viewbox>
        </StatusBar>
    </DockPanel>
</Window>
